package com.rcm.junit;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;



import org.apache.ibatis.session.SqlSession;
import org.junit.Before;
import org.junit.Test;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rcm.dao.AdmininfoMapper;
import com.rcm.dao.CoursesinfoMapper;
import com.rcm.dao.StudentinfoMapper;
import com.rcm.dao.TeacherinfoMapper;
import com.rcm.model.Admininfo;
import com.rcm.model.Coursesinfo;
import com.rcm.model.Studentinfo;
import com.rcm.model.Teacherinfo;
import com.rcm.utility.MyBatisTool;



public class Select {
	
	private SqlSession seesion;
	private StudentinfoMapper mapper;
	private List<Teacherinfo> list;
	
	@Before
	public void setUp(){
		seesion=MyBatisTool.getSession();
		mapper=seesion.getMapper(StudentinfoMapper.class);

	}

	@Test
	public void test() {
		CoursesinfoMapper mapper=seesion.getMapper(CoursesinfoMapper.class);
		Coursesinfo r=mapper.selectByPrimaryKey("3177");
	System.out.println(r);
	}
	
	
	 @Test
	 
	public void testAll(){
		List<Studentinfo> list=mapper.selectAll();//查询所有
		for(Studentinfo c:list)
			System.out.println(c);
	}
	 @Test
	 
		public void testadminAll(){
		 
		 	SqlSession session2=MyBatisTool.getSession();
			AdmininfoMapper mapper3 = session2.getMapper(AdmininfoMapper.class);
			
			List<Admininfo> list=mapper3.selectAll();//查询所有
			for(Admininfo c:list)
				System.out.println(c);
		}
	 
	 @Test
		public void selectBypage(){
		 
		 	SqlSession session4=MyBatisTool.getSession();
		 	TeacherinfoMapper mapper4 = session4.getMapper(TeacherinfoMapper.class);
			PageHelper.startPage(1,5);
			List<Teacherinfo> list=mapper4.selectBypage();//查询所有
			for(Teacherinfo c:list)
				System.out.println(c);
		
	 PageInfo<Teacherinfo> pageInfo=new  PageInfo<Teacherinfo>(list);
	 System.out.println(pageInfo);
	 
	 }
	 @Test
	 public void testtiem() {
		 Date date= new Date();
		 SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		 String time=df.format(date);
		 System.out.println(time);
		 
		 
	 }

}
